using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Resources;
using System.Globalization;

namespace HexLib
{
    public sealed class Language
    {
        private Language()
        { }

        private static Type typeFather = null;

        private static ResourceManager resmgr = null;

        private static System.Globalization.CultureInfo ci = null;

        public static System.Globalization.CultureInfo Culture
        {
            get { return Language.ci; }
            set { Language.ci = value; }
        }

        private static string nameResources = "";

        public static Type TypeFather
        {
            get { return typeFather; }
            set { typeFather = value; }
        }

        public static string NameResources
        {
            get { return Language.nameResources; }
            set
            {
                Language.nameResources = value;
                resmgr = new ResourceManager(Language.nameResources,
                              typeFather.Assembly);
            }
        }

        public static string GetMessage(string msg)
        {
            if(resmgr==null)
                resmgr = new ResourceManager(Language.nameResources,
                              typeFather.Assembly);
            try
            {

                return resmgr.GetString(msg, ci);
            }
            catch
            {
                return msg;
            }
        }
    }
}
